package com.yixing.tech.common.vo.s5;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author yixing tech
 * at 2022/2/11
 * describe：
 */
@Data
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
public class ActionVO {

    String protocolId;
    String protocolName;
    String operatorType;
    String targetId;
    String funCode;
    List<ObjModelVO.Param> params;
    Map<String,String> paramMap;
    String code;
    String desc;
    String type;
    String direction = "0";
    String iotId;
    String modelId;

    /**
     * list 2 map
     * @return
     */
    public Map<String,String> parseParams(){
        Map<String,String> map = new HashMap<>(10);
        if(params!=null){
            for(ObjModelVO.Param param:params){
                if(param == null)continue;
                map.put(param.getAttr(),param.getValue());
            }
        }
        this.paramMap = map;
        return map;
    }


    public void setMeterNo(String meterNo){
        if(paramMap == null)paramMap = new HashMap<>(10);
        paramMap.put("meterNo",meterNo);
    }

}
